package com.qire.manhua.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.FrameLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class CanInterceptFrameLayout extends FrameLayout {

    private boolean needIntercept = false;

    public CanInterceptFrameLayout(@NonNull Context context) {
        super(context);
    }

    public CanInterceptFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public CanInterceptFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public void setNeedIntercept(boolean needIntercept){
        this.needIntercept = needIntercept;
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        if(needIntercept)
            return true;
        return super.onInterceptTouchEvent(ev);
    }

}
